package cn.autumnorange.app.user.api;

import cn.autumnorange.app.common.dto.ResultDto;
import cn.autumnorange.app.user.api.dto.GramtedAuthorityImpl;
import feign.hystrix.FallbackFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class SysRoleFallbackFactory implements FallbackFactory<SysRoleService> {
  @Override
  public SysRoleService create(Throwable throwable) {
    return new SysRoleService() {
      @Override
      public ResponseEntity<ResultDto<List<GramtedAuthorityImpl>>> getRolesByUserId(long userId) {
        //                return ResultDto.createErrorResult(throwable.getMessage());
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR.value())
            .body(ResultDto.createMessageResult(throwable.getMessage()));
      }

      @Override
      public ResultDto<List<GramtedAuthorityImpl>> getRolesById(long userId) {
        return null;
      }
    };
  }
}
